/**
 * 
 */
package com.surelution.core;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.util.zip.ZipFile;

/**
 * @author <a href="mailto:guangzong.syu@gmail.com">Guangzong</a>
 *
 */
public class ValidatorLoader {

	public static SystemInfo load() {
		String filePath = "sn.key";
		try {
			ZipFile zipFile = new ZipFile(filePath);
			InputStream fis = zipFile.getInputStream(zipFile.getEntry(""));
			ObjectInputStream ois = new ObjectInputStream(fis);
			Object o = ois.readObject();
			return (SystemInfo) o;
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		
		return null;
	}
	
	public static SystemInfo load(InputStream is) throws IOException, ClassNotFoundException {
		ObjectInputStream ois = new ObjectInputStream(is);
		Object o = ois.readObject();
		ois.close();
		return (SystemInfo) o;
	}
}
